[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
##############################################################################
###+--------+#################################################################
#+-| LOCATE |----------------------------------------------------+############
#| +--------+ The LOCATE command positions the record pointer to |############
#| the first record matching the search criteria |############
#| within an alias |############
#+---------------------------------------------------------------+############
##############################################################################
##############################################################################
#+--| Syntax |---------------------------------------------------+############
#| [!<Alias>] LOCATE [Scope][WHILE <L-exp>][FOR <L-exp>] |############
#+---------------------------------------------------------------+############
##############################################################################
##############################################################################
########+---| Description |-------------------------------------------+#######
########| The default scope for LOCATE is ALL. To search for the |#######
########| next record matching the search criteria, use the CONTINUE |#######
########| command. |#######
########| ----------------------------------------------------------- |#######
########| If a match is found, then found() returns TRUE. |#######
########| ----------------------------------------------------------- |#######
########| The found flag is not associated with a specific database. |#######
########| It is only associated with the last LOCATE or SEEK command. |#######
########+-------------------------------------------------------------+#######
##############################################################################
##############################################################################
#########+--| Example 1 |-------------------------------------------+#########
#########| * LOCATE the first supplier of a CVT2300 or |#########
#########| * HC MP phone system. |#########
#########| |#########
#########| USE "equip.dbf" ALIAS equip |#########
#########| LOCATE ALL FOR equip->phone = 'CVT2300' .OR.; |#########
#########| equip->phone = 'HC MP' |#########
#########+----------------------------------------------------------+#########
##############################################################################
##############################################################################
#########+--| Example 2 |-------------------------------------------+#########
#########| * LOCATE all patients with fractures. |#########
#########| |#########
#########| !patients LOCATE WHILE patients->admit =; |#########
#########| ctod(today()) FOR patients->problem = 'fracture' |#########
#########| |#########
#########| DO WHILE found() |#########
#########| |#########
#########| !patients EDIT RECORD recno() |#########
#########| !patients CONTINUE |#########
#########| |#########
#########| ENDDO |#########
#########+----------------------------------------------------------+#########
##############################################################################
##############################################################################
#########+--| Example 3 |-------------------------------------------+#########
#########| * Because FORCE allows multiple filters |#########
#########| * per database alias, Query By Example can |#########
#########| * easily be programmed. |#########
#########| |#########
#########| VARDEF |#########
#########| CHAR search_name |#########
#########| CHAR search_car |#########
#########| ENDDEF |#########
#########| |#########
#########| PROCEDURE get_query |#########
#########| |#########
#########| ACCEPT "Query name: " TO search_name |#########
#########| ACCEPT " Query car: " TO search_car |#########
#########| |#########
#########| * Establish the filter criteria. |#########
#########| |#########
#########| SET FILTER TO |#########
#########| |#########
#########| IF search_name <> "" |#########
#########| SET FILTER TO cars->name = search_name ADDITIVE |#########
#########| ENDIF |#########
#########| |#########
#########| IF search_car <> "" |#########
#########| SET FILTER TO cars->car = search_car ADDITIVE |#########
#########| ENDIF |#########
#########| RETURN |#########
#########| |#########
#########| ENDPRO |#########
#########| |#########
#########| PROCEDURE force_main |#########
#########| |#########
#########| OPEN "autos.dbf" ALIAS cars |#########
#########| |#########
#########| DO WHILE .T. |#########
#########| DO get_query |#########
#########| IF search_name = 'Quit' |#########
#########| QUIT |#########
#########| ENDIF |#########
#########| |#########
#########| !cars LOCATE |#########
#########| |#########
#########| DO WHILE found() |#########
#########| EDIT |#########
#########| !cars CONTINUE |#########
#########| ENDDO |#########
#########| ENDDO |#########
#########| ENDPRO |#########
#########+----------------------------------------------------------+#########
##############################################################################
See Also:
CONTINUE
SET FILTER TO
a_eof()
eof()
found()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson